#include "StdAfx.h"
#include "Occlusion.h"

Occlusion::Occlusion(IXAudio2SourceVoice *pVoice, WAVEFORMATEXTENSIBLE* pwfx):EffectXAPO(pVoice, pwfx)
{
	IID apoIid = {1};
    CoCreateGuid( (GUID*)(&apoIid) );
	XAPO_REGISTRATION_PROPERTIES	 rep = { apoIid, L"Occlusion", L"occlusion",1, 2, XAPOBASE_DEFAULT_FLAG , 1, 1, 1, 1};;
	
	XAPOParameters.occlusionLevel = OCCLUSION_DEFAULT_LEVEL;
	BOOL fProducer = false;
	Occlus = new OcclusionXAPO(&rep, (BYTE*)&XAPOParameters, sizeof(OCCLUSION_PARAMETERS), fProducer, pwfx);
    Occlus->Initialize(NULL, 0);    
	
	pXAPO = (CXAPOBase*) Occlus;
}

Occlusion::~Occlusion(void)
{
	delete Occlus;
}

HRESULT Occlusion::apply(void)
{
	pSourceVoice->SetEffectParameters( GetEffectNumber(), &XAPOParameters, sizeof(OCCLUSION_PARAMETERS) );
	return S_OK;
}

OCCLUSION_PARAMETERS Occlusion::GetOcclusionParameters(void)
{
	return XAPOParameters;
}

OCCLUSION_PARAMETERS Occlusion::SetOcclusionParameters(const OCCLUSION_PARAMETERS & NewXAPOParameters)
{
	OCCLUSION_PARAMETERS OldXAPOParameters = XAPOParameters;
	XAPOParameters = NewXAPOParameters;
	return OldXAPOParameters;
}
